package com.example.demo.common;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-01-28
 * Time: 22:59
 */

public class Result {

    public static HashMap<String,Object> success(Object body) {
        HashMap<String,Object> map = new HashMap<>();
        //状态码-->成功状态码默认返回200
        map.put("code",200);
        //错误的信息
        map.put("message","");
        //数据
        map.put("data",body);
        return map;
    }

    public static HashMap<String,Object> success(Object body,String message) {
        HashMap<String,Object> map = new HashMap<>();
        //状态码-->成功状态码默认返回200
        map.put("code",200);
        //错误的信息
        map.put("message",message);
        //数据
        map.put("data",body);
        return map;
    }


    public static HashMap<String,Object> fail(Object body,Object message) {
        HashMap<String,Object> map = new HashMap<>();
        //状态码-->错误状态码
        map.put("code",-1);
        //错误的信息
        map.put("message",message);
        //数据
        map.put("data",body);
        return map;
    }

    public static HashMap<String,Object> fail(int code,Object body) {
        HashMap<String,Object> map = new HashMap<>();
        //状态码-->错误状态码
        map.put("code",code);
        //错误的信息
        map.put("message","");
        //数据
        map.put("data",body);
        return map;
    }

    public static HashMap<String,Object> fail(int code,Object body,Object message) {
        HashMap<String,Object> map = new HashMap<>();
        //状态码-->错误状态码
        map.put("code",code);
        //错误的信息
        map.put("message",message);
        //数据
        map.put("data",body);
        return map;
    }

}
